package com.test.ant.payment.service.impl;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.test.ant.payment.service.PaymentRemoteService;
import com.test.ant.payment.util.ConsultResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author ll
 * @Date 2018/1/10 20:37
 */
@Component("paymentRemoteService")
public class PaymentRemoteServiceImpl implements PaymentRemoteService {

    public static final int MAX_THREAD_COUNT = 8;

    private static final ExecutorService service = new ThreadPoolExecutor(
            MAX_THREAD_COUNT,
            MAX_THREAD_COUNT,
            0L,
            TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(1024),
            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("RealTime PaymentRemoteServiceImpl-%d").build(),
            new ThreadPoolExecutor.CallerRunsPolicy());

    @Override
    public ConsultResult isEnabled(String paymentType) {

        ConsultResult result = new ConsultResult();
        if (StringUtils.isNotEmpty(paymentType)) {

        }
        return result;
    }
}
